gnttab: correct maptrack table accesses
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:34:34 +0000 (14:34 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:34:34 +0000 (14:34 +0200)
commit4b78efa91c8ae3c42e14b8eaeaad773c5eb3b71a
tree7d5f32c4cf2869cd876aac8f8d2f71b565960fd6
parentb7f6cbb9d43f7384e1f38f8764b9a48216c8a525
gnttab: correct maptrack table accesses

In order to observe a consistent (limit,pointer-table) pair, the reader
needs to either hold the maptrack lock (in line with documentation) or
both sides need to order their accesses suitably (the writer side
barrier was removed by commit dff515dfea ["gnttab: use per-VCPU
maptrack free lists"], and a read side barrier has never been there).

Make the writer publish a new table page before limit (for bounds
checks to work), and new list head last (for racing maptrack_entry()
invocations to work). At the same time add read barriers to lockless
readers.

Additionally get_maptrack_handle() must not assume ->maptrack_head to
not change behind its back: Another handle may be put (updating only
->maptrack_tail) and then got or stolen (updating ->maptrack_head).

This is part of XSA-218.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/common/grant_table.c